package gbench.sandbox.record;

import org.junit.jupiter.api.Test;
import gbench.common.tree.LittleTree.IRecord;
import gbench.common.tree.LittleTree.KVPair;
import gbench.common.tree.LittleTree.Tuple2;
import static gbench.common.tree.LittleTree.KVPair.kvpclc;
import static gbench.common.tree.LittleTree.Tuple2.TUP2;

import java.util.stream.Collectors;
import static gbench.common.tree.LittleTree.*;
import static gbench.common.tree.LittleTree.IRecord.A;

public class JunitKVP {
    
    @Test
    public void foo() {
        final var rec = Tuple2.TUP2(1,2).multiSet1("ABCDEFGH".split("")).stream()
            .map(KVPair::new)
            .collect(kvpclc(IRecord::KVS2REC));
        System.out.println(rec);
    }
    
    @Test
    public void bar () {
        final var tpl = "ABCEDEFG";
        final var rec = NATS(100).map(kvp()).map(p->(char)tpl.charAt(p._1(intmod((long)tpl.length())))).collect(Collectors.toList());
        rec.stream().map(kvp()).forEach(e->{
            if(!e._1().equals(0l) && e._1()%tpl.length()==0)System.out.println();
            System.out.print(e);
        });
    }
    
    @Test
    public void qux3() {
        var a = TUP2(2,1).cons(3).cons(4).cons(5).cons(6);
        System.out.println(a);
        a.flatMap(e->e).forEach(System.out::println);
    }
    
    @Test
    public void qux4() {
        Tuple2.zip(A(1,3),A(1,2,3,4,5,6,7,8,9),true).forEach(tup->{
            System.out.println(tup);
        });
    }
    
    @Test
    public void qux5() {
        NATS(10).map(kvp(5)).forEach(System.out::println);
    }
}
